﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Web.Mvc;
using SimpComm;


namespace DAL.Enums
{

    #region 企业基本类型
    /// <summary>
    /// 企业基本类型
    /// </summary>
    public class emComp_State : MyEnum<byte>
    {
        public static readonly emComp_State All = new emComp_State(255, "所有状态");
        public static readonly emComp_State NotCoop = new emComp_State(0, "未入驻企业");
        public static readonly emComp_State WaitCheck = new emComp_State(1, "待验证企业");
        public static readonly emComp_State IsCoop = new emComp_State(2, "入驻企业");

        /// <summary>
        /// 自动生成List
        /// </summary>
        private static List<emComp_State> _Items;
        public static List<emComp_State> Items
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_State)field.GetValue(null)).ToList();
                }
                return _Items;
            }
        }
        public static JsonResult Get_JsonResult
        {
            get { return new JsonResult() { Data = Items, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
        }

        public static List<MyEnum<byte>> BaseItems
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_State)field.GetValue(null)).ToList();
                }
                return _Items.Select(p => p as MyEnum<byte>).ToList();
            }
        }
        public static emComp_State Get(byte value)
        {
            return Items.SingleOrDefault(p => p.Value == value);
        }

        public static emComp_State Get(string text)
        {
            var data = Items.SingleOrDefault(p => p.Text == text);
            if (data != null)
            {
                return data;
            }
            else
            {
                var i = Commons.ConvertHelper.ObjToIntNull(text);
                if (i.HasValue)
                    return Get((byte)i.Value);
            }
            return null;
        }

        //私有构造函数,有效阻止在类型外部生成实例
        private emComp_State(byte value, string text)
        {
            _Value = value;
            _Text = text;
        }
    }
    #endregion

    #region 企业联系人屏蔽类型
    public class emComp_Contact_Hidden : MyEnum<byte>
    {
        public static readonly emComp_Contact_Hidden NotHide = new emComp_Contact_Hidden(0, "不屏蔽");
        public static readonly emComp_Contact_Hidden HidePhone = new emComp_Contact_Hidden(1, "屏蔽电话联系方式");
        public static readonly emComp_Contact_Hidden AllHide = new emComp_Contact_Hidden(2, "屏蔽所有联系方式");

        /// <summary>
        /// 自动生成List
        /// </summary>
        private static List<emComp_Contact_Hidden> _Items;
        public static List<emComp_Contact_Hidden> Items
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_Contact_Hidden)field.GetValue(null)).ToList();
                }
                return _Items;
            }
        }
        public static JsonResult Get_JsonResult
        {
            get { return new JsonResult() { Data = Items, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
        }

        public static List<MyEnum<byte>> BaseItems
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_Contact_Hidden)field.GetValue(null)).ToList();
                }
                return _Items.Select(p => p as MyEnum<byte>).ToList();
            }
        }
        public static emComp_Contact_Hidden Get(byte value)
        {
            return Items.SingleOrDefault(p => p.Value == value);
        }

        public static emComp_Contact_Hidden Get(string text)
        {
            var data = Items.SingleOrDefault(p => p.Text == text);
            if (data != null)
            {
                return data;
            }
            else
            {
                var i = Commons.ConvertHelper.ObjToIntNull(text);
                if (i.HasValue)
                    return Get((byte)i.Value);
            }
            return null;
        }

        //私有构造函数,有效阻止在类型外部生成实例
        private emComp_Contact_Hidden(byte value, string text)
        {
            _Value = value;
            _Text = text;
        }
    }
    #endregion

    #region 企业合作类型
    /// <summary>
    /// 企业合作类型
    /// </summary>
    public class emComp_Coop : MyEnum<byte>
    {
        public static readonly emComp_Coop All = new emComp_Coop(255, "所有状态");
        public static readonly emComp_Coop NotCoop = new emComp_Coop(0, "未入驻企业");
        public static readonly emComp_Coop WaitCheck = new emComp_Coop(1, "待验证企业");
        public static readonly emComp_Coop IsCoop = new emComp_Coop(2, "入驻企业");


        /// <summary>
        /// 自动生成List
        /// </summary>
        private static List<emComp_Coop> _Items;
        public static List<emComp_Coop> Items
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_Coop)field.GetValue(null)).ToList();
                }
                return _Items;
            }
        }
        public static JsonResult Get_JsonResult
        {
            get { return new JsonResult() { Data = Items, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
        }

        public static List<MyEnum<byte>> BaseItems
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_Coop)field.GetValue(null)).ToList();
                }
                return _Items.Select(p => p as MyEnum<byte>).ToList();
            }
        }
        public static emComp_Coop Get(byte value)
        {
            return Items.SingleOrDefault(p => p.Value == value);
        }

        public static emComp_Coop Get(string text)
        {
            var data = Items.SingleOrDefault(p => p.Text == text);
            if (data != null)
            {
                return data;
            }
            else
            {
                var i = Commons.ConvertHelper.ObjToIntNull(text);
                if (i.HasValue)
                    return Get((byte)i.Value);
            }
            return null;
        }

        //私有构造函数,有效阻止在类型外部生成实例
        private emComp_Coop(byte value, string text)
        {
            _Value = value;
            _Text = text;
        }
    }
    #endregion

    #region 企业人数
    /// <summary>
    /// 企业人数
    /// </summary>
    public class emComp_People_Num : MyEnum<byte>
    {
        public static readonly emComp_People_Num All = new emComp_People_Num(255, "所有状态");
        public static readonly emComp_People_Num enull = new emComp_People_Num(0, "没有确定");
        public static readonly emComp_People_Num e1_10 = new emComp_People_Num(1, "1到10人");
        public static readonly emComp_People_Num e20_30 = new emComp_People_Num(2, "20到30人");


        /// <summary>
        /// 自动生成List
        /// </summary>
        private static List<emComp_People_Num> _Items;
        public static List<emComp_People_Num> Items
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_People_Num)field.GetValue(null)).ToList();
                }
                return _Items;
            }
        }
        public static JsonResult Get_JsonResult
        {
            get { return new JsonResult() { Data = Items, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
        }

        public static List<MyEnum<byte>> BaseItems
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_People_Num)field.GetValue(null)).ToList();
                }
                return _Items.Select(p => p as MyEnum<byte>).ToList();
            }
        }
        public static emComp_People_Num Get(byte value)
        {
            return Items.SingleOrDefault(p => p.Value == value);
        }

        public static emComp_People_Num Get(string text)
        {
            var data = Items.SingleOrDefault(p => p.Text == text);
            if (data != null)
            {
                return data;
            }
            else
            {
                var i = Commons.ConvertHelper.ObjToIntNull(text);
                if (i.HasValue)
                    return Get((byte)i.Value);
            }
            return null;
        }

        //私有构造函数,有效阻止在类型外部生成实例
        private emComp_People_Num(byte value, string text)
        {
            _Value = value;
            _Text = text;
        }
    }
    #endregion

    #region 企业需要服务状态
    /// <summary>
    /// 企业需要服务状态
    /// </summary>
    public class emComp_Service_State : MyEnum<byte>
    {
        public static readonly emComp_Service_State All = new emComp_Service_State(255, "所有状态");
        public static readonly emComp_Service_State NotService = new emComp_Service_State(0, "无需服务");
        public static readonly emComp_Service_State Comp_Wait = new emComp_Service_State(1, "追单中");
        public static readonly emComp_Service_State Comp_Coop = new emComp_Service_State(2, "入驻企业");
        public static readonly emComp_Service_State Comp_NoFuture = new emComp_Service_State(8, "木有前途");
        public static readonly emComp_Service_State Comp_Hate = new emComp_Service_State(9, "卤面客户");

        /// <summary>
        /// 自动生成List
        /// </summary>
        private static List<emComp_Service_State> _Items;
        public static List<emComp_Service_State> Items
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_Service_State)field.GetValue(null)).ToList();
                }
                return _Items;
            }
        }
        public static JsonResult Get_JsonResult
        {
            get { return new JsonResult() { Data = Items, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
        }

        public static List<MyEnum<byte>> BaseItems
        {
            get
            {
                if (_Items == null)
                {
                    var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                    _Items =
                        _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                            field => (emComp_Service_State)field.GetValue(null)).ToList();
                }
                return _Items.Select(p => p as MyEnum<byte>).ToList();
            }
        }
        public static emComp_Service_State Get(byte value)
        {
            return Items.SingleOrDefault(p => p.Value == value);
        }

        public static emComp_Service_State Get(string text)
        {
            var data = Items.SingleOrDefault(p => p.Text == text);
            if (data != null)
            {
                return data;
            }
            else
            {
                var i = Commons.ConvertHelper.ObjToIntNull(text);
                if (i.HasValue)
                    return Get((byte)i.Value);
            }
            return null;
        }

        //私有构造函数,有效阻止在类型外部生成实例
        private emComp_Service_State(byte value, string text)
        {
            _Value = value;
            _Text = text;
        }
    }
    #endregion
}

